#include <iostream>

#include <nemesis.functions.h>

#include <nemesis.xml.Node.h>
#include <nemesis.xml.Compiler.h>

#include <nemesis.tools.Encoder.h>

using namespace std;
using namespace nemesis;

int main ()
{
   char str [256];
   
   tools::Encoder encoder;
   tools::EncodedData other;
   
   xml::Compiler xmlCompiler;
   
   try {
      cout << "Introduce cadena: " << flush;
      
      while (gets (str) != 0) {
         const tools::EncodedData& edata = encoder.encode (str);

         xml::Node root ("tools.Encoder");
         cout << "XML: " << xmlCompiler.apply (edata.asXML (&root)) << endl;
         
         cout << "Original Decoded: " << functions::asString (encoder.decode (edata)) << endl << endl;
         
         other.initialize (&root);
         cout << "Copied Decoded: " << functions::asString (encoder.decode (other)) << endl << endl;
                  
         cout << "Introduce cadena: " << flush;
      }
   }
   catch (Exception& ex) {
      cout << ex.asString () << endl;
   }
}

